package com.x.erp.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.InsuranceClueDao;
import com.x.erp.model.InsuranceClue;
import com.x.erp.rpc.InsuranceClueRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;

/**
 * 保险线索信息服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.InsuranceClueRpcService", timeout = 60000)
public class InsuranceClueService extends BaseService implements InsuranceClueRpcService {

	@Autowired
	private InsuranceClueDao insuranceClueDao;// 保险线索信息dao

	/**
	 * 保险线索列表
	 * 
	 * @param insuranceClue
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<InsuranceClue> selectInsuranceClueList(InsuranceClue insuranceClue) {
		try {
			return insuranceClueDao.selectInsuranceClueList(insuranceClue);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增保险线索
	 * 
	 * @param insuranceClue
	 * @return
	 * @throws Exception
	 */
	@Override
	public InsuranceClue insertInsuranceClue(InsuranceClue insuranceClue) {
		try {
			insuranceClue.setClueCreateTime(this.getDate(0));
			return this.insert(insuranceClue);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询保险线索总数
	 * 
	 * @param insuranceClue
	 * @return
	 * @throws Exception
	 */
	@Override
	public int selectInsuranceClueNum(InsuranceClue insuranceClue) {
		try {
			return insuranceClueDao.selectInsuranceClueNum(insuranceClue);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

}
